<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('外协合同费用列表')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/navigation.css">
</head>
<body class="gray-bg">
<div class="navigation visible-xs-block">
    <ol class="breadcrumb">
        <span> > </span>
        <li><a href="#" onclick="gomain()">主页</a></li>
        <li style="color: black">项目合同费用</li>
    </ol>
    <div class="aLine"></div>
</div>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="pName"/>
                        </li>
                        <!--<li>
                            <label>合同方：</label>
                            <input type="text" name="pContractor"/>
                        </li>
                        <li>
                            <label>金钱：</label>
                            <input type="text" name="pMoney"/>
                        </li>
                        <li class="select-time">
                            <label>创建日期：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPCreate]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPCreate]"/>
                        </li>-->
                        <li class="select-time">
                            <label>创建时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:salary:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:salary:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:salary:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:costofcontract:exports">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table" style="color: black;font-size: 15px"> </table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script src="../../../../../../../../../../../../js/breadcrumb.js"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ruoyi:costofcontract:edit')}]];
    var prefix = ctx + "ruoyi/costofcontract";
    $(function() {
        var options = {
            url: prefix + "/list",
           /* updateUrl: prefix + "/edit/{id}",*/
            exportUrl: prefix + "/exports",
            detailUrl: prefix + "/detail/{id}",
            mobileResponsive: false,
            cardView: true,
            showColumns: false,
            detailView: true,
            striped: 'true',
            sortName:'pTime',
            sortOrder: 'desc',
            modalName:'项目合同费用',
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            rowStyle:{
                css:{"height":"50px"}
            },
            columns: [{
                field: 'pId',
                title: '项目id',
                visible: false
                 },
                {
                    field: 'pName',
                    title: '项目名称'
                },
                {
                    field: 'pTime',
                    title: '创建时间',
                    sortable: true,
                }]
        };
        $.table.init(options);
    });
    initChildTable = function (index, row, $detail) {
        var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: prefix + "/listss",
            //updateUrl: prefix + "/edit/{id}",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            sortName:'pCreate',
            sortOrder: 'desc',
            showFooter: true,
            queryParams: {
                sId:row.pId
            },
            rowStyle:{
                css:{"background":"lightyellow"}
            },
            columns: [

                {
                    field: 'pId',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'pName',
                    title: '合同名称'
                },
                {
                    field: 'pContractor',
                    title: '合同方'
                },
                {
                    //field: 'pMoney',
                    title: '金额',
                    cellStyle:{
                        css:{"color":"#0000EE","background":"lightyellow"}
                    },
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('￥'+row.pMoney)
                        return actions.join('');
                    },
                    footerFormatter: function(value){
                        var sum = 0;
                        for (var i in value) {
                            sum += parseFloat(value[i].pMoney)
                        }
                        return "合同总金额: ￥"+sum;
                    }
                },
                {
                    //field: 'pPaid',
                    title: '已付金额',
                    cellStyle:{
                        css:{"color":"#0000EE","background":"lightyellow"}
                    },
                    formatter: function (value, row, index) {
                        var pPaid = [];
                        pPaid.push('￥'+row.pPaid);
                        return pPaid.join('');
                    },
                    footerFormatter: function(value){
                        var sumpPaid = 0;
                        for (var i in value) {
                            sumpPaid += parseFloat(value[i].pPaid)
                        }
                        return "已付款总金额: ￥"+sumpPaid;
                    }
                },
                {
                    //field: 'pNotpaid',
                    title: '未付金额',
                    cellStyle:{
                        css:{"color":"#0000EE","background":"lightyellow"}
                    },
                    // formatter:function (value, row, index) {
                    //     var pnotpaid = [];
                    //     pnotpaid.push(row.pMoney-row.pPaid)
                    //     return pnotpaid.join('')
                    // }
                    formatter: function (value, row, index) {
                        var pNotpaid = [];
                        pNotpaid.push('￥'+row.pNotpaid)
                        return pNotpaid.join('');
                    },
                    footerFormatter: function(value){
                        var sumpNotpaid = 0;
                        for (var i in value) {
                            sumpNotpaid += parseFloat(value[i].pNotpaid)
                        }
                        return "未付款总金额: ￥"+sumpNotpaid;
                    }
                },
                {
                    field: 'pCreate',
                    title: '创建日期'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        /*actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + rows.pId + '\')"><i class="fa fa-search"></i>添加文件</a> ');*/
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.pId + '\')"><i class="fa fa-edit"></i>添加已付金额</a> ');
                        return actions.join('');
                    }
                }
                ]
        });
    };
    /* 财务管理-修改 */
    function edit(pId) {
        var url = prefix + '/edit/' + pId;
        $.modal.openFull("添加已付金额", url);
    }
</script>
</body>
</html>